<?php


namespace App\Transformers\Store;


use App\Models\LiveAnchor;
use App\Models\StoreBargainUser;
use App\Models\StoreBargainUserHelp;
use App\Transformers\User\UserTransformer;
use League\Fractal\TransformerAbstract;

class StoreBargainUserHelpTransformer extends TransformerAbstract
{
    protected $availableIncludes = ['user'];

    public function transform(StoreBargainUserHelp $data)
    {
        return [
            'id' => $data->id,
            'user_id' =>$data->user_id ?? "",
            'bargain_id' =>$data->bargain_id ?? "",
            'bargain_user_id' =>$data->bargain_user_id ?? "",
            'price' =>$data->price ?? "",
            'type' =>$data->type ?? 0,
            'created_at' => $data->created_at ? $data->created_at->format("Y-m-d H:i:s") : "",
            'updated_at' => $data->updated_at ? $data->updated_at->format("Y-m-d H:i:s") : "",
        ];
    }

    /**
     *额外包含用户数据
     */

    public function includeUser(StoreBargainUserHelp $storeBargainUserHelp)
    {
        return $this->item($storeBargainUserHelp->user, new UserTransformer());
    }

}
